package com.interagriculture.common;

import com.interagriculture.enums.ExceptionCodeEnum;

/**
 * @author 11 2024/11/9
 */
public class CustomException extends RuntimeException{
        //异常状态码
        private Integer code;

        /**
         * 通过状态码和错误消息创建异常对象
         * @param message
         * @param code
         */
        public CustomException(String message,Integer code){
            super(message);
            this.code = code;
        }

        /**
         * 根据响应结果枚举对象创建异常
         * @param
         */
        public CustomException(ExceptionCodeEnum exceptionCodeEnum){
            super(exceptionCodeEnum.getMessage());
            this.code = exceptionCodeEnum.getCode();
        }
        public CustomException(String message){
            super(message);
        }


        @Override
        public String toString() {
            return "LeaseException{" +
                    "code=" + code +
                    ", message=" + this.getMessage() +
                    '}';
        }
    }

